package org.jash.shop2202

import androidx.databinding.ObservableInt
import androidx.lifecycle.lifecycleScope
import com.alibaba.android.arouter.launcher.ARouter
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import org.jash.shop2202.databinding.ActivityMainBinding
import org.jash.shop2202.mvvm.BaseActivity
import org.jash.shop2202.mvvm.BaseViewModel

class MainActivity : BaseActivity<ActivityMainBinding, BaseViewModel>() {
    val count by lazy { ObservableInt(3) }
    override fun initData() {
        lifecycleScope.launch {
            binding.progress.max = count.get()
            for (i in count.get() downTo 0) {
                count.set(i)
                binding.progress.setProgress(i, true)
                delay(1000)
            }
//            startActivity(Intent(this@MainActivity, LoginActivity::class.java))
            ARouter.getInstance().build("/shop/login")
                .navigation()
            finish()
        }
    }

    override fun initView() {
        binding.count = count
    }

}